<template>
    <div style="width: 100%">
        <div id="deawer">
            <v-tableTitle :btnConfig="btnConfig" @cancel="cancel" @save="save"></v-tableTitle>
            <div class="detailBox">
                <v-detail ref="detail"></v-detail>
            </div>
            <div class="detailListBox">
                <v-detailList ref="detailList"></v-detailList>
            </div>
        </div>
    </div>

</template>

<script>
    import baseMixin from "@/mixins/BaseMixin";
    import skipMixin from "@/mixins/SkipMixin";
    import config from "../Config";
    import detail from "../details/Detail"
    import detailList from "../detailsList/DetailList"
    import tableTitle from "commons/TableTitle";

    export default {
        name: "",
        mixins: [baseMixin, skipMixin, config],
        data() {
            return {
                flag: true,
                detailFlag: false,
                newFlag: false
            };
        },
        created() {
        },
        computed: {
            btnConfig() {
                return [
                    {label: this.$t('common.save'), certigier: this.saveStatus, invalid: "save"},
                    {label: this.$t('common.return'), invalid: "cancel"},
                ]
            }
        },
        methods: {
            //保存按钮
            async save() {
                /*let detail = this.$refs.detail.detailData;
                let detailList;
                if (this.$refs.detailList) {
                    detailList = this.$refs.detailList.detailData;
                    this.detailFlag = this.$refs.detailList.detailsFlag;
                }

                let data = {};
                if (this.newFlag) {
                    data = {
                        ...detail,
                    }
                } else if (this.detailFlag) {
                    data = {
                        ...detail,
                        detailList: [{...detailList, contract_key: detail.contract_key}]
                    }
                } else {
                    data = {
                        ...detail,
                    }
                }
                try {
                    let res = await this.$api.post(`/saveContract/${this.$store.state.wms}`, data);
                    
                        this.$message.success(res.returnMgr);
                        if (this.detailFlag) {
                            this.$refs.detailList.detailsFlag = false;
                            this.$refs.detailList.detailNav = "1";
                        } else {
                            this.cancel();
                        }
                    
                } catch (e) {
                    this.$message.error(e)
                }*/

            },
            //弹框取消
            cancel() {
                this.$router.push({name: "checkbom"});
            },
        },
        mounted() {
            this.newFlag = this.$store.state.newFlag;
            if (Object.keys(this.$store.state.skip).length !== 0) {
                let data = this.$store.state.skip;
                this.detailsFlag = data.detailListFlag;
            }

        },
        watch: {},
        components: {
            "v-detail": detail,
            "v-detailList": detailList,
            "v-tableTitle": tableTitle,
        }
    }
</script>

<style scoped>

</style>
